package com.nvwa.mvp.mybatis.controller;

import com.github.pagehelper.PageInfo;
import com.nvwa.dto.query.PageQuery;
import com.nvwa.dto.resp.Response;
import com.nvwa.mvp.mybatis.model.UserModel;
import com.nvwa.mvp.mybatis.po.User;
import com.nvwa.mvp.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/get")
    public Response getUser() {
        User u = userService.getUser();
        return Response.success(u);
    }

    @PostMapping("/page")
    public Response<PageInfo<UserModel>> pageUser(@RequestBody PageQuery query) {
        PageInfo<UserModel> pageInfo = userService.pageUser(query);
        return Response.success(pageInfo);
    }

}